home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 3.8 KB | 122 lines | [TEXT/MPS ] |
- {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
- { UViewCoords.p }
- { Copyright © 1987-1990 by Apple Computer, Inc. All rights reserved. }
-
- {$IFC UNDEFINED UsingIncludes}
- {$SETC UsingIncludes := FALSE}
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- UNIT UViewCoords;
-
- INTERFACE
- {$ENDC}
-
- {$IFC UNDEFINED UsingUViewCoords}
- {$SETC __UViewCoords__ := FALSE}
- {$ENDC}
-
- {$IFC NOT __UViewCoords__}
- {$SETC __UViewCoords__ := TRUE}
-
- { • Auto-Include the requirements for this unit's interface. }
- {$SETC UViewCoordsIncludes := UsingIncludes}
- {$SETC UsingIncludes := TRUE}
- {$I+}
- {$IFC UNDEFINED __UMacAppUtilities__} {$I UMacAppUtilities.p} {$ENDC}
- {$SETC UsingIncludes := UViewCoordsIncludes}
-
- CONST
- kMaxCoord = 30000; { largest possible QuickDraw view coordinate
- (QuickDraw maximum minus slop for size of
- screen) }
-
- { Calculations with VPoints }
-
- PROCEDURE PtToVPt(thePt: Point;
- VAR theVPt: VPoint);
- { Convert a QD Point to a VPoint. }
-
- FUNCTION VPtToPt(theVPt: VPoint): Point;
- { Convert a VPoint to a QD Point. }
-
- PROCEDURE AddVPt(srcVPt: VPoint;
- VAR dstVPt: VPoint);
- { Adds the coordinates of 'srcVPt' to the coordinates of 'dstVPt' returning result in
- 'dstVPt'. }
-
- PROCEDURE SubVPt(srcVPt: VPoint;
- VAR dstVPt: VPoint);
- { Subtracts the coordinates of 'srcVPt' from the coordinates of 'dstVPt' returning result in
- 'dstVPt'. }
-
- PROCEDURE SetVPt(VAR vPt: VPoint;
- h, v: VCoordinate);
- { Assigns the two given coordinates to 'vPt'. }
-
- FUNCTION EqualVPt(pt1, pt2: VPoint): BOOLEAN;
- { Compares the two VPoints returning TRUE if they are equal and FALSE if not. }
-
- { Calculations with VRects }
-
- PROCEDURE RectToVRect(theRect: Rect;
- VAR theVRect: VRect);
- { Converts a QD Rect to a VRect. }
-
- PROCEDURE VRectToRect(theVRect: VRect;
- VAR theRect: Rect);
- { Converts a VRect to a QD Rect. }
-
- PROCEDURE SetVRect(VAR r: VRect;
- left, top, right, bottom: VCoordinate);
- { Sets the boundary coordinates of the VRect 'r' . }
-
- PROCEDURE OffsetVRect(VAR r: VRect;
- dh, dv: VCoordinate);
- { Moves the given VRect by adding 'dh' to each horizontal and 'dv' to each vertical
- coordinate. Postive values cause the movement to be to the right and down, while negative
- are the opposite. }
-
- PROCEDURE InsetVRect(VAR r: VRect;
- dh, dv: VCoordinate);
- { Shrinks or expands the given VRect.The left and right sides are moved in by 'dh', the top
- and bottom by 'dv'. If the values are negative the movement is outward. }
-
- FUNCTION PtInVRect(pt: VPoint;
- r: VRect): BOOLEAN;
- { Determines whether the pixel below and to the right of the given coordinate is enclosed by
- the specified VRect, returns TRUE if so or FALSE if not. }
-
- FUNCTION SectVRect(src1, src2: VRect;
- VAR dstRect: VRect): BOOLEAN;
- { Calculates the VRect that is the intersection of the two given VRects, returns TRUE if they
- intersect and FALSE if not. }
-
- FUNCTION EmptyVRect(r: VRect): BOOLEAN;
- { Returns TRUE if the given VRect is an empty VRect, FALSE if not. }
-
- FUNCTION EqualVRect(rectA, rectB: VRect): BOOLEAN;
- { Compares the two given VRects and returns TRUE if they are equal FALSE if not. }
-
- FUNCTION LengthVRect(r: VRect;
- vhs: VHSelect): VCoordinate;
- { Returns the length of the given VRect in the direction determined by 'vhs'. }
-
- PROCEDURE PinVRect(r: VRect;
- VAR pt: VPoint);
- { Pins the given VPoint to the given VRect. }
-
- PROCEDURE UnionVRect(src1, src2: VRect;
- VAR dstRect: VRect);
- { Calculates the smallest VRect that encloses both the given VRects, returns the result in
- 'dstRect'. }
-
- PROCEDURE Pt2VRect(topLeft, botRight: VPoint;
- VAR dstRect: VRect);
- { Returns the smallest VRect that encloses to given VPoints. }
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- END.
- {$ENDC}
-